{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PyTorch练习1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#请输出你的姓名\n",
    "print('')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 使用tensor与自动求导编写并训练一个线性回归器"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "print(torch.__version__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#生成训练数据\n",
    "x = torch.rand(30,2)*10 - 5 \n",
    "w0 = torch.tensor([2,-1],dtype = torch.float32)\n",
    "b0 = torch.tensor([1.7],dtype = torch.float32)\n",
    "y = torch.matmul(x,w0) + b0 + torch.randn(30) #受随机噪声污染的y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "from mpl_toolkits.mplot3d import Axes3D\n",
    "xarr = x.numpy()\n",
    "yarr = y.numpy()\n",
    "fig = plt.figure(0, figsize=(4, 3))\n",
    "plt.clf()\n",
    "ax = Axes3D(fig, elev=45, azim=100)\n",
    "ax.scatter(x[:, 0], x[:, 1], y)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#编写模型并训练\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.6.5 64-bit",
   "language": "python",
   "name": "python36564bit32ad07c40e574f4b931fcdc5269dba63"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
